<?php
namespace app\admin\validate;


class AdminMenuValidate extends BaseValidate
{
    public function __construct()
    {
        $rule = [
            'parent_id' => 'require|number',
            'order_num' => 'require|number',
            "path"      => "require|max:255|unique:company_menu",
            "component" => "require|max:255",
            "query"     => "require|max:255",
            "is_frame"  => "require|in:0,1",
            "menu_type" => "require|in:M,C,F",
            "visible"   => "require|in:0,1",
            "perms"     => 'require|max:255',
            "icon"      => 'require|max:255'
        ];

        $message = [
            "parent_id.require" => "父级菜单不能为空",
            "parent_id.number"  => "父级菜单必须为数字",
            "order_num.require" => "排序值不能为空",
            "order_num.number"  => "排序值必须为数字",
            "path.require"      => "路由地址不能为空",
            "path.max"          => "路由地址长度不能超过255",
            "path.unique"       => "路由地址已经存在",
            "component.require" => "组件路径不能为空",
            "component.max"     => "组件路径长度不能超过255",
            "query.require"     => "路由参数不能为空",
            "query.max"         => "路由参数长度不能超过255",
            "is_frame.require"  => "是否为外链不能为空",
            "is_frame.in"       => "是否为外链值错误",
            "menu_type.require" => "菜单类型不能为空",
            "menu_type.in"      => "菜单类型值错误",
            "visible.require"   => "显示状态不能为空",
            "visible.in"        => "显示状态值错误",
            "perms.require"     => "权限标识不能为空",
            "perms.max"         => "权限标识长度不能超过255",
            "icon.require"      => "菜单图标不能为空",
            "icon.max"          => "菜单图标长度不能超过255",
        ];

        $scene = [
            "add" => ["parent_id", "order_num", "name", "menu_type"],
        ];
        parent::__construct($rule, $message, $scene);
    }
}